home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Text and Fonts / FontNames / FontNames.cs next >
Encoding:
Text File  |  2001-01-15  |  1.2 KB  |  39 lines

  1. //----------------------------------------
  2. // FontNames.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class FontNames: PrintableForm
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new FontNames());
  13.      }
  14.      public FontNames()
  15.      {
  16.           Text = "Font Names";
  17.      }
  18.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  19.      {    
  20.           string[]    astrFonts = { "Courier New", "Arial", 
  21.                                     "Times New Roman" };
  22.           FontStyle[] afs       = { FontStyle.Regular, FontStyle.Bold, 
  23.                                     FontStyle.Italic,  
  24.                                     FontStyle.Bold | FontStyle.Italic };
  25.           Brush       brush     = new SolidBrush(clr);
  26.           float       y         = 0;
  27.  
  28.           foreach (string strFont in astrFonts)
  29.           {
  30.                foreach (FontStyle fs in afs)
  31.                {
  32.                     Font font = new Font(strFont, 18, fs);
  33.                     grfx.DrawString(strFont, font, brush, 0, y);
  34.                     y += font.GetHeight(grfx);
  35.                }
  36.           }
  37.      }
  38. }
  39.